package de.uni_mannheim.informatik.ai.dame_ai.util;

import java.awt.Color;




public class GameState {

	private Color[] nodes=new Color[24];
	private int depositWhite, depositBlack;
	private String playerWhite, playerBlack;
	private Color toPlay;
	private boolean millClosed=false;
	
	
	public boolean isMillClosed() {
		return millClosed;
	}

	public void setMillClosed(boolean millClosed) {
		this.millClosed = millClosed;
	}

	public GameState(int whiteDeposit, int blackDeposit) {
		depositWhite=whiteDeposit;
		depositBlack=blackDeposit;
		for(int i=0; i<24; i++){
			this.setOccupant(i, null);
		}
	}

	public Color getOccupant(int node) {
		return nodes[node];
	}

	public void setOccupant(int node, Color occupant) {
		this.nodes[node] = occupant;
	}

	public String getWhitePlayer() {
		return playerWhite;
	}

	public String getBlackPlayer() {
		return playerBlack;
	}

	public void setPlayers(String white, String black) {
		this.playerWhite = white;
		this.playerBlack = black;
	}


	public Color getToPlay() {
		return toPlay;
	}


	public void setToPlay(Color toPlay) {
		this.toPlay = toPlay;
	}

	public int getDepositWhite() {
		return depositWhite;
	}

	public int getDepositBlack() {
		return depositBlack;
	}
	
	@Override
	public String toString() {
		String ret=
			"Game State: ---------------------------------\n" +
			"white player: "+playerWhite + ", black player: "+playerBlack +"\n" +
			"colorToPlay: "+toPlay +"\n" +
			"White stones in deposit: "+depositWhite+"; Black stones in deposit: "+depositBlack +"\n" +
			"Fields:\n";
		for(int i=0; i<24; i++){
			ret+= i+")"+getOccupant(i)+"; ";
		}
		ret +="\n---------------------------------------------";
		return ret;
	}
	
	
	/**
	 * @return A Game state Object that holds the initial state of the Mill Game.
	 */
	public static GameState getInitialState(){
		GameState initial=new GameState(9, 9);
		initial.toPlay=Color.WHITE;
		return initial;
	}
}
